<!-- 客户联系电话控件 -->
<template>
  <a-space direction="vertical" style="width: 100%">
    <a-input v-model="phone" disabled :placeholder="props.props.placeholder" />
  </a-space>
</template>

<script lang="ts" setup>
  import { ref, computed, watchEffect } from 'vue';
  import miiter from '@/utils/mitt';

  const props = withDefaults(
    defineProps<{
      props: { [propName: string]: any };
      name?: string;
      required?: boolean;
      oneValue: any;
      regex?: {
        [name: string]: {
          role: any;
          name: any;
        };
      };
    }>(),
    {}
  );
  const emit = defineEmits(['update:oneValue']);

  const phone = computed({
    get: () => {
      return props.oneValue;
    },
    set: (val) => {
      emit('update:oneValue', val);
    },
  });

  // miiter.emit('key', { key: 1 });

  watchEffect(() => {
    miiter.on('clientRefresh', (val: any) => {
      if (val.key === 'client') {
        phone.value = val.item.customerContactPhone;
      } else {
        phone.value = val.item.contactPhone;
      }
    });
  });
</script>

<style scoped lang="less"></style>
